package ve.ejb.metadata;

import java.awt.Color;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import ve.ejb.entity.DimensionalCut;
import ve.ejb.entity.Pointer;

/**
 *
 * @author memozac
 */
@Entity
public class Comparator implements Serializable {
    private static final long serialVersionUID = 1L;

    public enum Type{REAL,GOAL,CUSTOM};

    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idComparator;

    @ManyToMany(targetEntity=Color.class) @JoinTable(name="PointerComparator", joinColumns=@JoinColumn(name="idComparator"),
    inverseJoinColumns=@JoinColumn(name="idPointer")) private Collection<Pointer> pointers;    

    @ManyToMany(targetEntity=Color.class) @JoinTable(name="ComparatorDimensionalCut", joinColumns=@JoinColumn(name="idComparator"),
    inverseJoinColumns=@JoinColumn(name="idDimensionalCut")) private Collection<DimensionalCut> registers;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    @Column(columnDefinition="text") private String name;
    
    @Column(columnDefinition="text") private String description;

    @Enumerated private Type type;

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Collection<DimensionalCut> getRegisters() {
        return registers;
    }

    public void setRegisters(Collection<DimensionalCut> registers) {
        this.registers = registers;
    }

    public Long getIdComparator() {
        return idComparator;
    }

    public void setIdComparator(Long idComparator) {
        this.idComparator = idComparator;
    }

    public Collection<Pointer> getPointers() {
        return pointers;
    }

    public void setPointers(Collection<Pointer> pointers) {
        this.pointers = pointers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idComparator != null ? idComparator.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Comparator)) {
            return false;
        }
        Comparator other = (Comparator) object;
        if ((this.idComparator == null && other.idComparator != null) || (this.idComparator != null && !this.idComparator.equals(other.idComparator))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.Comparator[id=" + idComparator + "]";
    }

}//ends of class
